package com.cloud.code.并发包;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 相比于callable+future来说优点就是,在多线程中,当某个线程执行完毕后回立马执行FutrueTask中的done方法来处理接下来的事务
 */
public class CallableFutureTask {
	public static void main(String[] args) {
		ExecutorService executor = Executors.newCachedThreadPool();
		for(int i=0; i<1000; i++) {
			MyTask myTask = new MyTask("name"+i);
			MyFutureTask ft = new MyFutureTask(myTask);
			executor.submit(ft);
		}
		executor.shutdown();
	}

}

